var idd = 1;
           
			
	
			
            function add() {
            	var name = $("#name").val();
				
				var sex;
				
				var sexs = document.getElementsByName("sexN");
		
				for(var i =0;i<sexs.length;i++){
					if(sexs[i].checked==true){
						
						sex =sexs[i].value;
					}
				}
				
				
				
			 var habbit="";
			 var habbits =  document.getElementsByName("hobbitid");
			
				for(var i=0;i<habbits.length;i++){
					if(habbits[i].checked==true){
				       habbit+=habbits[i].value+" ";
					}
				}
				
			  var address = $("#address_id").val();	


            	var html = "" +
            		"<tr id='tr"+idd+"'>" +
            		"<td style='width: 9.375rem;' id ='td"+idd+"'>" + idd + "</td>" +
            		"<td style='width: 9.375rem;' id ='tdN"+idd+"'>" + name + "</td>" +
            		"<td style='width: 9.375rem;' id ='tdS"+idd+"'>" + sex + "</td>" +
					"<td style='width: 14.375rem;' id ='tdH"+idd+"'>" + habbit + "</td>" +
					"<td style='width: 14.375rem;' id ='tdA"+idd+"'>" + address + "</td>" +
            		"<td style='width: 9.375rem;' id ='tdC"+idd+"'> <a href ='javascript:;' onclick='testupd("+idd+")'>修改</a> <a href='javascript:;'  onclick='testdel("+idd+")'>删除</a>" +
            		"</tr>"
            	$("#tbody").append(html);
				
            	idd++;
			
				habbit="";
             


            }
			
			function testdel(idd){
				if(confirm("你确定要删除吗?")){
					
				$("#tr"+idd).remove();
			
				}
			
			}
			
			function testupd(idd){
				
				$("#tdN"+idd).html('<input type="text" id="nameup'+idd+'" placeholder="姓名" value= '+$("#tdN"+idd).text()+' >');
				
			
				 $("#tdS"+idd).html('<input type="text" id="sexup'+idd+'" placeholder="性別" value='+$("#tdS"+idd).text()+'>');
				  $("#tdH"+idd).html('<input type="text" id="hobbitup'+idd+'" placeholder="愛好" value='+$("#tdH"+idd).text()+'>');
	
				 $("#tdA"+idd).html('<input type="text" id="addressup'+idd+'" placeholder="地址" value= '+$("#tdA"+idd).text()+'>');
				 $("#tdC"+idd).html('<a href= "javascript:" onclick ="save('+idd+')" value = "保存">保存</a>');
				
				
				
				
				
				
			}
			
			function save(idd){
				
				var html = "" +
					
					"<td style='width: 9.375rem;' id ='td"+idd+"'>" + idd + "</td>" +
					"<td style='width: 9.375rem;' id ='tdN"+idd+"'>" + $("#nameup"+idd).val() + "</td>" +
					"<td style='width: 9.375rem;' id ='tdS"+idd+"'>" + $("#sexup"+idd).val() + "</td>" +
					"<td style='width: 14.375rem;' id ='tdH"+idd+"'>" + $("#hobbitup"+idd).val() + "</td>" +
					"<td style='width: 14.375rem;' id ='tdA"+idd+"'>" + $("#addressup"+idd).val() + "</td>" +
					"<td style='width: 9.375rem;' id ='tdC"+idd+"'> <a href ='javascript:;' onclick='testupd("+idd+")'>修改</a> <a href='javascript:;'  onclick='testdel("+idd+")'>删除</a>" 
				
				
				 $("#tr"+idd).html(html);
				
			}
			
			function select(){
				var select_name = $("#select_name").val();
				var select_address= $("#address_select").val();
				// alert(select_name)
				// alert(select_address)
				
				
				for(var i=0;i<idd;i++){
					// alert($("#tdN"+i).text())
				if( ($("#tdN"+i).text()==select_name) && ($("#tdA"+i).text()==select_address)){
					$("#tr"+i).css("background","red");
				}
					
				}
				
				
				
			}
			
